from copy import deepcopy


def get_list_1(nlist: list):
    list_1 = []
    for i in range(len(nlist) - 1):
        tmp_list = deepcopy(nlist)
        x = nlist[i] + nlist[i + 1]
        tmp_list.insert(i, x)
        del tmp_list[i + 2]
        del tmp_list[i + 1]
        list_1.append(tmp_list)
    return list_1


def get_children(nlist):
    children = []
    for item in nlist:
        i = item.index(-2)
        head = item[:i + 3]
        tail = item[i + 2:]
        print(item)
        list_1 = get_list_1(tail)
        for each in list_1:
            print(head + each)
            # children.append(head + each)

        # result = get_children(list_1)
        # for each in result:
        #     print(head, sum(head), len(head))
        #     print(each, sum(each), len(each))
        #     children.append(head + each)

    return children


def main(n):
    initial_list = [-1] * n
    print(initial_list)
    list_1 = get_list_1(initial_list)
    children = get_children(list_1)

    list_1.extend(children)
    # for item in list_1:
    #     print(sum(item))

    print(len(list_1))


main(20)
